package com.gonsin.gview.general.utils;

import java.util.HashMap;
import java.util.Map;

public class TypeUtils {

    private static Map<String, String> JAVA_TO_SQL;
    static {
        Map<String, String> m = new HashMap<>();
        m.put("String", "varchar(64)");
        m.put("int", "int(8)");
        m.put("Integer", "int(8)");
        m.put("long", "bitint(16)");
        m.put("Long", "bitint(16)");
        m.put("boolean", "tinyint(1)");
        m.put("Boolean", "tinyint(1)");
        m.put("byte", "int(4)");
        m.put("Byte", "int(4)");
        m.put("shot", "int(6)");
        m.put("Shot", "int(6)");
        m.put("float", "decimal(6, 2)");
        m.put("Float", "decimal(6, 2)");
        m.put("double", "decimal(8, 2)");
        m.put("Double", "decimal(8, 2)");
        JAVA_TO_SQL = m;
    }

    /**
     * 获取数据库类型
     */
    public static String getDbType(String javaType){
        return JAVA_TO_SQL.getOrDefault(javaType, "text");
    }

}
